<div class="main layui-clear">
    <div class="wrap">
        <div class="content detail">
            <div class="fly-panel detail-box">
                <h1>
                    <?php echo $question['title'] ?>
                </h1>
                <div class="fly-tip fly-detail-hint">
                    <span class="fly-tip-jie">
                        <?php echo $question['status'] ?> <!-- 状态未结贴 -->
                    </span>
                    <div class="jie-admin-box" data-id="8973">
                    </div>
                    <div class="fly-list-hint">
                        <a href="#comment">
                            <i class="iconfont" title="回答">
                                &#xe60c;
                            </i>
                            <?php echo $question['answer_num'] ?>
                        </a>
                        <i class="iconfont" title="人气">
                            &#xe60b;
                        </i>
                        <?php echo $question['view_num'] ?>
                    </div>
                </div>
                <div class="detail-about">
                    <a class="jie-user" href="{:U('home/u/index',array('id'=>$question['uid']))}">
                        <img src="__ROOT__<?php echo $question['face'] ?>"
                        alt="细雨无声">
                        <cite>
                            <?php echo $question['nickname'] ?>  <!-- 用户名 -->
                            <em>
                                发布于<?php echo CT($question['create_time']) ?><!-- 发布于17小时前 -->
                            </em>
                        </cite>
                    </a>
                    <div class="detail-hits" id="LAY_jieAdmin" data-id="8973">
                        <span style="color:#FF7200">
                            悬赏：<?php echo $question['kiss_num'] ?>飞吻
                        </span>
                        <span class="layui-btn layui-btn-mini jie-admin " type="collect" data-type="add">收藏</span>
                    </div>
                </div>
                <div class="detail-body photos">
                    <!-- 数据库里面存的是实体 输出时用htmlspecialchars_decode反转实体为不带标签的 -->
                    <?php echo htmlspecialchars_decode($question['content']) ?>
                </div>
            </div>
            <div class="fly-panel" style="height: 90px;">
                <script type="text/javascript">
                    /*728*90 创建于 2017/3/17*/
                    var cpro_id = "u2927108";
                </script>
                <script type="text/javascript" src="//cpro.baidustatic.com/cpro/ui/c.js">
                </script>
            </div>
            <div class="fly-panel detail-box" style="padding-top: 0;">
                <ul class="jieda photos" id="jieda">
                <!-- 如果empty检测到的当前问题的回复$answers为空，则是true，显示没有任何回复 -->
                <?php if(empty($answers)){ ?>
                    <li class="fly-none">
                        没有任何回复
                    </li>
                <?php }else{ ?>
                    <?php foreach ($answers as $row) { ?>
                    <li data-id="30799" class="jieda-daan">
                        <a name="item-1491381701291">
                        </a>
                        <div class="detail-about detail-about-reply">
                            <a class="jie-user" href="{:U('home/u/index',array('id'=>$row['uid']))}">
                                <img src="__ROOT__<?php echo $row['face'] ?>" alt="放逐之魚">
                                <cite>
                                    <i>
                                        <?php echo $row['nickname'] ?> <!-- 回复的id -->
                                    </i>
                                </cite>
                            </a>
                            <div class="detail-hits">
                                <span>
                                    <?php echo CT($row['create_time']) ?> <!-- 回复时间 -->
                                </span>
                            </div>
                            <i class="iconfont icon-caina" title="最佳答案">
                            </i>
                        </div>
                        <div class="detail-body jieda-body">
                            <?php echo htmlspecialchars_decode($row['content']) ?> <!-- 回复的内容 反转实体-->
                        </div>
                        <div class="jieda-reply">
                            <span class="jieda-zan " type="zan">
                                <i class="iconfont icon-zan">
                                </i>
                                <em>
                                    <?php echo $row['zan_num'] ?>
                                </em>
                            </span>
                            <span type="reply">
                                <i class="iconfont icon-svgmoban53">
                                </i>
                                回复
                            </span>
                        </div>
                    </li>
                    <?php } ?>
                <?php } ?>
                    

                    
                </ul>

                <div class="layui-form layui-form-pane">
                    <form action="/jie/reply/" method="post">
                        <div class="layui-form-item layui-form-text">
                            <a name="comment">
                            </a>
                            <div class="layui-input-block">
                                <textarea id="L_content" name="content" required lay-verify=""
                                placeholder="我要回答" class="layui-textarea fly-editor" style="height: 150px;"></textarea>
                                
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <!-- <input type="hidden" name="jid" value="8973"> -->

                            <!-- 隐藏域里放个当前问题的id，异步提交回复时可抓到 qid=6-->
                            <input type="hidden" name="qid" value="<?php echo $question['id'] ?>">
                            <button class="layui-btn" lay-filter="addanswer" lay-submit>
                                提交回答
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="edge">
        <!-- <?php var_dump($hotView) ?> -->
        <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                最近热帖
            </dt>
            <?php foreach ($hotView as $row) { ?>
                <dd>
                <!-- 点击热帖的标题 跳转到该贴的页面home/jie/index，并带上参数id=循环的值$row['id'] -->
                <a href="{:U('home/jie/index',array('id'=>$row['id']))}">
                    <?php echo $row['title'] ?>
                </a>
                <span>
                    <i class="iconfont">
                        &#xe60b;
                    </i>
                    <?php echo $row['view_num'] ?>
                </span>
                </dd>    
            <?php } ?>
        </dl>
        <!-- <div class="fly-panel">  <a href="https://www.mysubmail.com/sms?s=layui" target="_blank" rel="nofollow">    <img src="http://cdn.layui.com/upload/2017_3/168_1490947206404_96548.jpg" style="border-radius: 2px; max-width: 100%;" alt="赛邮云通信">  </a></div> -->
        <!-- <div class="fly-panel">
            <a href="http://layim.layui.com/?from=fly" target="_blank">
                <img src="//cdn.layui.com/upload/2017_4/168_1491409129785_72772.png" style="border-radius: 2px; max-width: 100%;"
                alt="LayIM">
            </a>
        </div> -->
        <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                近期热议
            </dt>
            <?php foreach ($hotAnswer as $row) { ?>
                <dd>
                <a href="{:U('home/jie/index',array('id'=>$row['id']))}">
                    <?php echo $row['title'] ?>
                </a>
                <span>
                    <i class="iconfont">
                        &#xe60c;
                    </i>
                    <?php echo $row['answer_num'] ?>
                </span>
                </dd>
            <?php } ?>
        </dl>
        <div class="fly-panel">
            <script type="text/javascript">
                /*336*280*/
                var cpro_id = "u2482656";
            </script>
            <script type="text/javascript" src="//cpro.baidustatic.com/cpro/ui/c.js">
            </script>
        </div>
    </div>
</div>
     <script type="text/javascript">
          layui.use(['form','jquery','layedit'], function(){
          var form = layui.form(),
          layer = layui.layer,
          $ = layui.jquery;
          layedit = layui.layedit;
         
  
      
      
      //插入图片接口配置
      layedit.set({
          uploadImage: {
            url: '{:U('home/jie/uploadImage')}' //接口url
            ,type: '' //默认post
          }
        });


      
      //创建编辑器并将编辑器放在index存起来，后面可用
      index = layedit.build('L_content', {
        height: 180 //设置编辑器高度
        });


      //监听提交
      form.on('submit(addanswer)', function(data){

        //获得编辑器内容
        content = layedit.getContent(index);

        //alert(content);

        if (content.length<20) {
            layer.msg("问题描述不能低于20",
                    function(){});
            return false;
        }
        //console.log(data);
        data.field.content = content;//同步文本框内容及图片，不然只抓到文本内容，抓不到图片,把做完最新的白色content放在蓝色中

        $.ajax({ 
            
            url: '{:U('home/jie/addAnswer')}',
            type: 'POST',
            dataType: 'json',
            data: data.field,
            
        })
        .done(function(respones) { //回答回应respones接到通讯成功后返回的arr
            if (respones.error==1) {
                layer.msg(respones.info,
                    function(){});  
            }else{
                layer.alert(respones.info, {icon: 6}, function(){
                    location.reload() // location.reload 英文重新装的意思  刷新当前页面
                });
                    
            }
            
        })
        .fail(function() {
            console.log("error");
        })
        
        
        return false;
      });
      
      
    });
    </script>   